import math
class HeigthException(Exception):
    def __init__(self,value):
        self.value = value
    def __hex__(self):
        return '异常信息：身高应处于0.3~2.5，输入的身高是：{}'\
            .format(self.value)
def  computeBMI():
    heigth = float(input('请输入身高（m):'))
    if heigth < 0.3 or heigth > 2.5:
        raise HeigthException(heigth)
    weigth = float(input('请输入体重（kg）：'))
    BMI = weigth / math.pow(heigth,2)
    if BMI < 18.5:
        print('消瘦')
    elif BMI < 24:
        print('正常')
    elif BMI < 28:
        print('超重')
    else:
        print('肥胖')
try:
    computeBMI()
except HeigthException as e:
    print(e)
except ValueError:
    print('输入的数据异常，请输入浮点数或整数！')
